import { getData, postData } from '@/api/ik/data/dataApi'
import store from '@/store/index'

// 所有权限用户菜单
export function getAllUser(token) {
  return new Promise((resolve, reject) => {
    getData('/kams/role/find/all', 'get', {
      searchData: {

      },
      orderData: {},
      token: token
    })
      .then(response => {
        resolve(response)
      })
  })
}
// 所有权限菜单数据
export function getAllMenu(token) {
  return new Promise((resolve, reject) => {
    getData('/kams/menu/fi_getMenu', 'get', {
      token: token
    })
      .then(response => {
        resolve(response)
      // return response
      })
  })
}

// 获取某个用户的菜单权限
export function getUserData(token, userCode) {
  // 参数
  return new Promise((resolve, reject) => {
    getData('/kams/menu/fi_getAuthMenu', 'get', {
      token: token,
      userCode: userCode
    })
      .then(response => {
        resolve(response)
      })
  })
}
// 获取某类用户的菜单权限
export function getUserTypeData(token, roleCode) {
  // 参数
  return new Promise((resolve, reject) => {
    getData('/kams/menu/fi_getAuthMenuByRole', 'get', {
      token: token,
      roleCode: roleCode
    })
      .then(response => {
        resolve(response)
      })
  })
}

// 上传某个用户编码修改后的权限
export function postUserData(roleCode, list) {
  // 参数
  return new Promise((resolve, reject) => {
    postData('/kams/menu/do_saveAuthMenuFun', {
      roleCode: roleCode,
      menuBOList: list
    }, store.state.user.token)
      .then(response => {
        resolve('提交成功')
      })
  })
}

